package com.hit.sys.modular.user.controller;

import com.hit.core.pojo.response.ResponseData;
import com.hit.core.pojo.response.SuccessResponseData;
import com.hit.sys.modular.user.param.SysUserParam;
import com.hit.sys.modular.user.service.SysUserService;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

@RestController
public class SysUserController {

    @Resource
    private SysUserService sysUserService;

    @GetMapping("/sysUser/detail")
    public ResponseData detail(@Validated(SysUserParam.detail.class) SysUserParam sysUserParam){
        return new SuccessResponseData(sysUserService.detail(sysUserParam));
    }

    @PostMapping("/sysUser/add")
    public ResponseData add(@RequestBody @Validated(SysUserParam.add.class) SysUserParam sysUserParam) {
        sysUserService.add(sysUserParam);
        return new SuccessResponseData();
    }

    @PostMapping("/sysUser/edit")
    public ResponseData edit(@RequestBody @Validated(SysUserParam.edit.class) SysUserParam sysUserParam) {
        sysUserService.edit(sysUserParam);
        return new SuccessResponseData();
    }

    @PostMapping("/sysUser/delete")
    public ResponseData delete(@RequestBody @Validated(SysUserParam.delete.class) List<SysUserParam> sysUserParamList){
        sysUserService.delete(sysUserParamList);
        return new SuccessResponseData();
    }

}
